
const {ccclass, property} = cc._decorator;

@ccclass
export default class GameSpeakerUi extends cc.Component {

    @property(cc.Sprite)
    speakerNode: cc.Sprite = null;
    @property(cc.SpriteFrame)
    speakerLight: Array<cc.SpriteFrame> = []; 
    @property(cc.Label)
    timeLabel:cc.Label = null;
    endTime = 0;
    setSpeaker (speaker, time) {
        this.speakerNode.spriteFrame = this.speakerLight[speaker];
        this.endTime = time;
    }

    update (dt) {
        if (this.endTime) {
            this.timeLabel.string = Math.max(0, Math.floor((this.endTime - new Date().getTime())/1000)).toString();
        }
    }
}
